package cc.vicp.djx314.starfood.web.dish;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import cc.vicp.djx314.starfood.service.activity.CustomerActivityService;
import cc.vicp.djx314.starfood.service.dishes.RecommendDishesService;

/**
 * 主页获取推荐菜式的controller
 * @author Administrator
 *
 */
@Controller
public class IndexRecommendDishesController {
	//~属性=====================================================================
	@Autowired
	private RecommendDishesService recommendDishesService;
	@Autowired
	private CustomerActivityService customerActivityService;

	//~方法=====================================================================
	@RequestMapping(value = "/", method = RequestMethod.GET)
	public String contextPathToIndex() {
		return "redirect:/index";
	}

	@RequestMapping(value = "/index", method = RequestMethod.GET)
	public String indexRecommendDishes(Model model) throws Throwable {
		//recommendDishesService.getPreferentialDishes().get(0).setProvideAreas(new ArrayList<ProvideArea>());
		//加载首页管理员推荐信息
		model.addAttribute("preferentials", recommendDishesService.getPreferentialDishes());
		//model.addAttribute("preferentials", new ArrayList<Dish>());
		//加载首页本店热销信息
		model.addAttribute("hotSells", recommendDishesService.getHotSellDishes());
		//加载首页热门收藏信息
		model.addAttribute("collections", recommendDishesService.getCollectionDishes());
		//加载首页的餐厅活动信息
		model.addAttribute("activities", customerActivityService.getIndexActivities());
		//model.addAttribute("activities", new ArrayList<Activity>());
		return "customer/infoshow/index";
	}

	//~getter和setter=====================================================================
	public void setRecommendDishesService(
			RecommendDishesService recommendDishesService) {
		this.recommendDishesService = recommendDishesService;
	}
	public void setCustomerActivityService(
			CustomerActivityService customerActivityService) {
		this.customerActivityService = customerActivityService;
	}
}
